package service

import (
	"fmt"
	"github.com/go-vgo/robotgo"
	"github.com/kbinani/screenshot"
	"log"
)

type ScreenshotService struct{}

func (t *ScreenshotService) Screenshot() {
	// 捕获屏幕

	robotgo.Move(-2560, 159)
	//robotgo.MoveSmooth(-1, 158+1440)
	//robotgo.Move(0, 0)
	//robotgo.MoveSmooth(2559, 1599)
	n := screenshot.NumActiveDisplays()

	fmt.Printf("屏幕数量 %#v \n", n)
	for i := 0; i < n; i++ {

		x, y, w, h := robotgo.GetDisplayBounds(i)
		log.Printf("%#v  \t  %#v \t  %#v \t  %#v", x, y, w, h)

		//img, err := screenshot.CaptureDisplay(i)
		////bounds := screenshot.GetDisplayBounds(0)
		////img, err := screenshot.Capture(bounds.Min.X, bounds.Min.Y, bounds.Max.X, bounds.Max.Y)
		//if err != nil {
		//	fmt.Printf("screenshot err:%v\n", err)
		//	return
		//}
		//
		//// 压缩为JPEG
		//file, err := os.Create(fmt.Sprintf("D:/www/output-%d.jpg", i))
		//if err != nil {
		//	fmt.Printf("create file err:%v\n", err)
		//	return
		//}
		//defer file.Close()
		//
		//err = jpeg.Encode(file, img, &jpeg.Options{Quality: 75})
		//if err != nil {
		//	fmt.Printf("encode err:%v\n", err)
		//	return
		//}
	}
}
